var ClubNoticeUnit = Unit.extend({
    _ccsFileName: res.ClubNoticeUnit_json,
    _noticeContent: '',
    initUnit: function () {
        this._hideNoitce(true);

    },
    /**
     * View基类初始化
     */
    initView: function () {
        this._actionType = ViewActionType.None;
        if (this._actionType === ViewActionType.None) {
            this._rootNode.show();
        }
        this._loadCCSFinished = true;
        this.setData.apply(this, arguments);
    },
    onEnter: function () {
        Unit.prototype.onEnter.call(this);
        this._initAllListeners();
    },
    /**
     * 监听亲友圈消息
     * @private
     */
    _initEventListeners: function () {
        this._eventListeners = {};
        this._eventListeners[ClubEvent.ClubBaseInfo] = '_clubBaseInfoHandler';
    },

    _clubBaseInfoHandler: function (clubId) {
        var clubInfo = ClubDataManager.getClubData(clubId);
        if (!clubInfo) return;
        this._noticeContent = clubInfo['notice'] || '';
        this._noticeAction();
    },

    _noticeAction: function () {
        var self = this;
        this._nodeList['panel.textContent'].setContentSize(cc.size(this._noticeContent.length * 26, 25));
        this._nodeList['panel.textContent'].setString(this._noticeContent);
        var noticeY = this._nodeList['panel.textContent'].y;
        var startX = this._nodeList['panel.textContent'].width + 50;
        // var endX = -this._nodeList['panel'].getContentSize().width + 50;
        var endX = -(this._noticeContent.length * 30);
        var time = Math.round(this._noticeContent.length * 26 / 100);
        if (time < 10) {
            time = 10;
        }

        this._hideNoitce(false);
        this._nodeList['panel.textContent'].x = startX;
        var action = cc.sequence(cc.moveTo(time, cc.p(endX, noticeY)),
            cc.callFunc(function () {
                self._hideNoitce(true);
            }),
            cc.delayTime(3),
            cc.callFunc(function () {
                self._noticeAction();
            })
        );
        this._nodeList['panel.textContent'].stopAllActions();
        this._nodeList['panel.textContent'].runAction(action);
    },

    _hideNoitce: function (hide) {
        var opacity = hide ? 0 : 255;
        this._nodeList['panel.textContent'].setOpacity(opacity);
        this._nodeList['gonggao_bg'].setOpacity(opacity);
    },

});